/**
 * 
 */
package com.simtek.simplayer.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.simtek.simplayer.R.layout;
import com.simtek.simplayer.entry.YoutubeUrlMeta;

/**
 * @author Hitech
 * 
 */
public class QualityAdapter extends BaseAdapter {

	private LayoutInflater			inflater;
	private List<YoutubeUrlMeta>	data;

	public QualityAdapter(Context context) {
		super();
		inflater = LayoutInflater.from(context);
	}

	public void setData(List<YoutubeUrlMeta> data) {
		this.data = data;
	}

	@Override
	public int getCount() {
		if (data == null) {
			return 0;
		}
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		return data.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = inflater.inflate(layout.qualitiy_item_layout, parent,
					false);
		}
		YoutubeUrlMeta meta = (YoutubeUrlMeta) getItem(position);
		((TextView) convertView).setText(meta.height + "p");
		((TextView) convertView).append(" (" + meta.width + "x" + meta.height
				+ ")");
		return convertView;
	}

}
